package nacos.controller;

import nacos.feign.ProviderColonyClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class Client9903Controller {
    public static final String SERVER_URL = "http://provider-colony";

    @Value("${spring.application.name}")
    private String name;

    @Resource
    private RestTemplate restTemplate;

    /**
     * 使用restTemplate方式
     */
    @GetMapping("/c1")
    public String c1(){
        return this.name + "-" + restTemplate.getForObject(SERVER_URL + "/c1",String.class);
    }

    @Autowired
    private ProviderColonyClient providerColonyClient;
    /**
     * 使用Feign方式
     */
    @GetMapping("/c2")
    public String c2(){
        return this.name + "-" + providerColonyClient.c1();
    }
}
